package com.yydm.servicecount.controller;


import com.yydm.commonutils.R;
import com.yydm.servicecount.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author yydm
 * @since 2022-07-16
 */
@RestController
@RequestMapping("/count")
//@CrossOrigin
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService statisticsDailyService;

    @PostMapping("/test")
    public void test(){
        System.out.println("statisticsDailyService = " + statisticsDailyService);
    }
    //    统计某一天的注册人数 生成统计数据
    @PostMapping("/registerCount/{day}")
    public R registerCount(@PathVariable String day) {
        System.out.println("day = " + day);
        statisticsDailyService.registerCount(day);
        return R.ok();
    }

    //    显示echarts图表
    @GetMapping("/showCharts/{type}/{begin}/{end}")
    public R showCharts(@PathVariable String type,
                        @PathVariable String begin,
                        @PathVariable String end) {

        Map<String, Object> map = statisticsDailyService.getChartsData(type, begin, end);

        return R.ok().data(map);
    }


}
